package com.jtpay.sdk.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.channel.test.tblPassageTimeStatistics;

import java.util.List;

/**
 * Created by Joe on 2017/3/27 0027 10:54.
 */

public class TimerAdapetr extends BaseAdapter {
    private Context mContext;
    private List<tblPassageTimeStatistics> arrayList;
    public TimerAdapetr(Context context,List<tblPassageTimeStatistics> arrayList){
        this.mContext=context;
        this.arrayList=arrayList;
    }
    @Override
    public int getCount() {
        return arrayList.size();
    }

    @Override
    public Object getItem(int position) {
        return arrayList.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        final ViewHolder holder;
        if (convertView == null) {
            convertView = View.inflate(mContext, android.R.layout.simple_expandable_list_item_2, null);
            holder = new ViewHolder();
            holder.Item_Passage_Name= (TextView) convertView.findViewById(android.R.id.text1);
            holder.Item_Passage_Platform= (TextView) convertView.findViewById(android.R.id.text2);
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }
            holder.Item_Passage_Name.setText(arrayList.get(position).getPassageName());
            holder.Item_Passage_Platform.setText(String.format("%s\t%s",
                    arrayList.get(position).getPlatform(), arrayList.get(position).getPayType()));

        return convertView;
    }
    private final class ViewHolder {
        TextView Item_Passage_Name;
        TextView Item_Passage_Platform;
    }
}
